import React from 'react';
import {Link, useLocation} from "react-router-dom";
import {Card, Descriptions} from "antd";
import {Divider} from "antd/lib";

import LogFactory from "log/LogFactory";
import TreeEnhance from "common/tree/TreeEnhance";

const log = LogFactory.getLog("UserMenuComponent");
const UserMenuComponent = () => {
    const user = useLocation().state;

    log.debug("用户菜单管理") ;
    return (
        <Card
            title={"用户菜单管理"}
            extra={ <Link to={"../"}>用户列表</Link>}
        >
            <Descriptions column={2}>
                <Descriptions.Item label={"用户编号"}>{user.id}</Descriptions.Item>
                <Descriptions.Item label={"用户名"}>{user.username}</Descriptions.Item>
                <Descriptions.Item label={"用户身份"}>{user.identity}</Descriptions.Item>
                <Descriptions.Item label={"用户标识"}>{user.key}</Descriptions.Item>
            </Descriptions>
            <Divider/>
          <TreeEnhance
              id={user.id}
              dataUrl={"/manager/security-user-menu/tree/" + user.id}
              updateUrl={"/manager/security-user-menu/tree"}
              refreshUrl={"/root/admin/refresh-menu-tree/" + user.username}
          />
        </Card>
    );
};

export default UserMenuComponent;